clear all
program drop _all
set more off
set mem 600m

cd "C:\Users\master\Dropbox\Research\mexican_repatriates2\data\kwan"
use "D:\raw\1930.dta"

keep if age>=18 & age<=65

keep statefip sea county urban perwt

replace county = (1000*statefip) + (county/10)

* Arizona
replace county = 4009 if county == 4011

* Louisiana
replace county = 22097 if county == 22039
replace county = 22019 if county == 22011 | county == 22003 | county == 22053

* New Mexico
replace county = 35017 if county == 35023
replace county = 35019 if county == 35011
replace county = 35005 if county == 35025

* Nevada
replace county = 32013 if county == 32027
replace county = 32009 if county == 32021

* Oklahoma
replace county = 40031 if county == 40033

* Oregon
replace county = 41013 if county == 41031 | county == 41017

* Texas
replace county = 48141 if county == 48229 | county == 48109
replace county = 48137 if county == 48385
replace county = 48355 if county == 48273 | county == 42849
replace county = 48061 if county == 48489
replace county = 48427 if county == 48407

* Utah
replace county = 49047 if county == 49009
replace county = 49051 if county == 49013

gen urb = urban == 2

collapse (sum) urb pop=perwt, by(county)

*replace county=41061 if county==41060.5

gen s_urban = urb/pop

keep county s_urban
order county s_urban

save urban_share.dta, replace
